<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script src="jquery-3.7.1.min.js"></script>
</head>
<body>
    <h1>jQuery中使用AJAX</h1>
    <input type="button" value="发送请求get" onclick="test_get()">
    <input type="button" value="发送请求post" onclick="test_post()">
    <input type="button" value="发送请求get_args" onclick="test_get_args()">
    <input type="button" value="发送请求get_json" onclick="test_get_json()">
    <input type="button" value="发送请求post_args" onclick="test_post_args()">
    <input type="button" value="发送请求post_json" onclick="test_post_json()">
    <script>

        function test_get(){
            $.ajax({
                type:'get',
                url:'http://httpbin.org/get',
                success:(data)=>{
                    console.log(data)
                },
                error:(data)=>{
                    console.log(data)
                }
            })
        }

        function test_post(){
            $.ajax({
                type:'post',
                url:'http://httpbin.org/post',
                success:(data)=>{
                    console.log(data)
                },
                error:(data)=>{
                    console.log(data)
                }
            })
        }

        function test_get_args(){
            $.ajax({
                type:'get',
                url:'http://httpbin.org/get',
                data:'name=zs&pwd=123',
                success:(data)=>{
                    console.log(data)
                },
                error:(data)=>{
                    console.log(data)
                }
            })
        }

        function test_get_json(){
            $.ajax({
                type:'get',
                url:'http://httpbin.org/get',
                data: {'name':'zs','pwd':123},
                success:(data)=>{
                    console.log(data)
                },
                error:(data)=>{
                    console.log(data)
                }
            })
        }

        function test_post_args(){
            $.ajax({
                type:'post',
                url:'http://httpbin.org/post',
                data:'name=zs&pwd=123',
                success:(data)=>{
                    console.log(data)
                },
                error:(data)=>{
                    console.log(data)
                }
            })
        }

        function test_post_json(){
            $.ajax({
                type:'post',
                url:'http://httpbin.org/post',
                data: {'name':'zs','pwd':123},
                success:(data)=>{
                    console.log(data)
                },
                error:(data)=>{
                    console.log(data)
                }
            })
        }



    </script>
</body>
</html>